package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.List;

/**
 * 大攻略
 */
@Setter
@Getter
public class Strategy extends BaseDomain {

    public static final int STATE_NORMAL = 1;
    public static final int STATE_COMMEND = 2;
    public static final int STATE_DISABLE = 3;

    private Region place;//攻略所属地区

    private String title;//标题

    private String subTitle;//副标题

    private String coverUrl;//封面

    private Integer state = 1;//状态

    private Integer viewCount;//浏览数

    public String getStateName() {
        if (state != null) {
            if (state == STATE_NORMAL) {
                return "正常";
            } else if (state == STATE_COMMEND) {
                return "推荐";
            }
            return "禁用";
        }
        return "";
    }

    public String getJsonString() {
        HashMap<Object, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title", title);
        map.put("subTitle", subTitle);
        map.put("coverUrl", coverUrl);
        if (place != null) {
            map.put("placeId", place.id);
        }
        map.put("state", state);
        return JSONUtil.toJSONString(map);
    }

}